class lzu::wn (
  $has_gpu = "no",
  $allowusers = ["root"],
  )
  {

  $startd_soft_config = '/etc/condor/config.d/01-startd.conf'
  $startd_hard_config = '/etc/condor/config.d/01-startd-hard.conf'

  $condor_pkg = [
     "condor",
     "condor-classads",
     "condor-kbdd",
     "condor-procd",
     "condor-python",
     "condor-externals",
    ]
  yumrepo { "condor":
    baseurl => "http://${mirrorserver}/yum/condor/9.0/el${operatingsystemmajrelease}/release",
    descr => "condor",
    enabled => 1,
    gpgcheck => 0,
    priority => 20,
    before   => Yumrepo['site'],
  }

  package { $condor_pkg:
    ensure  => installed,
    require => Yumrepo['site'],
  } ->
  package {"condor-worker":
    ensure     => absent,
  } ->
  file {"/etc/condor/wrapper":
    ensure     =>  directory,
    mode       =>  '0755',
    owner      =>  'root',
    group      =>  'root',
  } ->
  file {"/etc/condor/wrapper/wrapper.sh":
    mode       =>  '0755',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/wrapper.sh",
    notify   => Exec['refresh_condor_wn']
  } ->
  file {"/etc/condor/config.d/01-startd.conf":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/01-startd.conf",
    notify   => Exec['refresh_condor_wn']
  } ->
  file {"/etc/condor/config.d/01-startd-hard.conf":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    content    =>  template("${module_name}/01-startd-hard.erb"),
    notify   => Exec['refresh_condor_wn']
  } ->
  file {"/etc/condor/config.d/02-gpu-start.conf":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    content    =>  template("${module_name}/02-gpu-start.erb"),
    notify   => Exec['refresh_condor_wn']
  } ->
  service { 'condor':
    ensure     => 'running',
    enable     => true,
    hasrestart => true,
    hasstatus  => true,
  }
  exec {'restart_condor_wn':
    command      => "/sbin/service condor restart",
    refreshonly  => true
  }
  exec {'refresh_condor_wn':
    command      => "/usr/sbin/condor_reconfig",
    refreshonly  => true
  }

  # disable other users
  sshd_config { 'AllowUsers':
    ensure => present,
    value  => $allowusers,
    notify => Service['sshd'],
  }

  cron { 'clean-scratch':
    command => "ls -al /scratch/ |grep -v  ' root '|grep -v condor|awk '{print \$9}'|xargs -I {} find /scratch/{} -maxdepth 1 -mtime +14  |xargs rm -rf",
    user    => 'root',
    hour    => 4,
    minute  => 33
  }


  firewall { '000 accept all icmp requests':
    proto  => 'icmp',
    action => 'accept',
  }->
  firewall { '001 accept all to lo interface':
    proto   => 'all',
    iniface => 'lo',
    action  => 'accept',
  }->
  firewall { '002 reject local traffic not on loopback interface':
    iniface     => '! lo',
    proto       => 'all',
    destination => '127.0.0.1/8',
    action      => 'reject',
  }->
  firewall { '003 accept related established rules':
    proto  => 'all',
    state  => ['RELATED', 'ESTABLISHED'],
    action => 'accept',
  }->
  firewall { '100 accept internal network':
    chain   => 'INPUT',
    proto   => 'all',
    source  => '192.168.0.0/16',
    action  => 'accept',
  }->
  firewall { '101 accept internal network':
    chain   => 'INPUT',
    proto   => 'all',
    destination   => '192.168.0.0/16',
    action   => 'accept',
  }->
  firewall { '102 accept internal network':
    chain   => 'INPUT',
    proto   => 'all',
    source   => '202.122.32.0/19',
    action   => 'accept',
  }->
  firewall { '103 accept internal network':
    chain   => 'INPUT',
    proto   => 'all',
    destination   => '202.122.32.0/19',
    action   => 'accept',
  }->
  firewall { '104 accept locaal network':
    chain   => 'INPUT',
    proto   => 'all',
    source  => '210.26.48.0/23',
    action  => 'accept',
  }->
  firewall { '105 accept locaal network':
    chain   => 'INPUT',
    proto   => 'all',
    destination  => '210.26.48.0/23',
    action  => 'accept',
  }->
  firewall { '999 drop all other requests':
    proto  => 'all',
    action => 'drop',
  }


}
